<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增链接')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-link-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">链接分类：</label>
                <div class="col-sm-8">
                    <input name="linkType" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">链接名称：</label>
                <div class="col-sm-8">
                    <input name="linkName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">关键词：</label>
                <div class="col-sm-8">
                    <input name="keywords" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">链接：</label>
                <div class="col-sm-8">
                    <input name="link" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <textarea name="descrition" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">Logo：</label>
                <div class="col-sm-8">
                    <input name="logo" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">审核状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('audit_state')}">
                        <input type="radio" th:id="${'auditState_' + dict.dictCode}" name="auditState" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'auditState_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">详情：</label>
                <div class="col-sm-8">
                    <input name="detail" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">允许评论：</label>
                <div class="col-sm-8">
                    <input type="hidden" id="commentFlag" name="commentFlag" value="0" >
                    <label class="toggle-switch switch-solid">
                        <input type="checkbox" id="checkbox_commentFlag">
                        <span></span>
                    </label>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        $(function(){
            $("#checkbox_commentFlag").on("change",function(){
                var v=$(this).prop("checked");
                if(v){
                    $("#commentFlag").val("1");
                }else{
                    $("#commentFlag").val("0");
                }
            });
        })
        var prefix = ctx + "cms/link"
        $("#form-link-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-link-add').serialize());
            }
        }
    </script>
</body>
</html>